﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ColladaDotNet;

namespace contentviewer.ViewModel
{
	class VisualSceneViewModel : NodeViewModel
	{
		readonly  visual_scene _visualScene;

		public VisualSceneViewModel(NodeViewModel root, NodeViewModel parent, visual_scene visualScene)
            : base(root, parent)
        {
			_visualScene = visualScene;
        }

		public string Content
		{
			get
			{
				var vizHeader = "";
				if (string.IsNullOrEmpty(_visualScene.name))
					vizHeader += "visual scene";
				else
					vizHeader += (_visualScene.name);

				if (!string.IsNullOrEmpty(_visualScene.GetId()))
					vizHeader += " <" + _visualScene.GetId() + ">";

				return vizHeader;
			}
		}

        protected override void LoadChildren()
        {
            base.LoadChildren();
			if (_visualScene.asset != null)
				base.Children.Add(new AssetViewModel(Root, this, _visualScene.asset));
			foreach (var node in _visualScene.node)
			{
				base.Children.Add(new VSNodeViewModel(Root, this, node));
			}
        }

		public override bool IsSelected
		{
			get
			{
				return base.IsSelected;
			}
			set
			{
				if (value == true)
					(Root as ColladaNodeViewModel).SelectedItems.Add(this);
				else
					(Root as ColladaNodeViewModel).SelectedItems.Remove(this);
				base.IsSelected = value;
			}
		}

		public override string ToString()
		{
			return this.Content;
		}
	}
}
